﻿using Fabrication.DataSources;
using Fabrication.ValueProviders;

namespace Fabrication
{
    public static class StringRuleExtensions
    {
        public static IBuilderOptions<T> GenerateGivenName<T>(this PropertySelector<T, string> propertySelector)
        {
            return propertySelector.Use(new GivenNameProvider());
        }

        public static IBuilderOptions<T> GenerateLastName<T>(this PropertySelector<T, string> propertySelector)
        {
            return propertySelector.Use(new LastNameProvider());
        }

        public static IBuilderOptions<T> GenerateFullName<T>(this PropertySelector<T, string> propertySelector)
        {
            return propertySelector.Use(new FullNameProvider());
        }

        public static IBuilderOptions<T> GenerateEmailAddress<T>(this PropertySelector<T, string> propertySelector)
        {
            return propertySelector.Use(new EmailProvider());
        }

        public static IBuilderOptions<T> GenerateUserName<T>(this PropertySelector<T, string> propertySelector)
        {
            return propertySelector.Use(new UserNameProvider());
        }

        public static IBuilderOptions<T> GenerateStreetName<T>(this PropertySelector<T, string> propertySelector)
        {
            return propertySelector.PickFrom(Streets.StreetNames);
        }

        public static IBuilderOptions<T> GenerateStreetType<T>(this PropertySelector<T, string> propertySelector)
        {
            return propertySelector.PickFrom(Streets.StreetTypes);
        }

        public static IBuilderOptions<T> GenerateStreet<T>(this PropertySelector<T, string> propertySelector)
        {
            return propertySelector.Use(new StreetProvider());
        }

        public static IBuilderOptions<T> GenerateAddress<T>(this PropertySelector<T, string> propertySelector)
        {
            return propertySelector.Use(new AddressProvider());
        }

        public static IBuilderOptions<T> GenerateCountry<T>(this PropertySelector<T, string> propertySelector)
        {
            return propertySelector.Use(new CountryProvider());
        }

        public static IBuilderOptions<T> GenerateLoremIpsum<T>(this PropertySelector<T, string> propertySelector, int? length = null)
        {
            return propertySelector.Use(new LoremIpsumProvider(length));
        }

        public static IBuilderOptions<T> GeneratePhoneNumber<T>(this PropertySelector<T, string> propertySelector)
        {
            return propertySelector.Use(new PhoneNumberProvider());
        }

        public static IBuilderOptions<T> UseRange<T>(this PropertySelector<T, string> propertySelector, int minimum, int maximum)
        {
            var provider = new FunctionValueProvider<T, string>(x => RandomNumberGenerator.GetInteger(minimum, maximum).ToString());
            return propertySelector.Use(provider);
        }
    }
}